Small fixes. Produces valid PSF files now.