change types around, preventing the integer division, so bug fixed.
first suitable image. lots of diagnostics output still though.
added comments
fixed bugs causing segmentation faults. beautiful. :)
testing for other functions. all ok.