I'm neither sure that this is fully correct nor that I found all occurences (so far, the output writing code is missing in this patch), but it seems to work for SPE1...