break out scaling code
fixed a bit (but can still be fooled, i bet!) - slight SNR increase over C version, but slower