fixed point conversion code (y range was not correct), refactored