General library code fixes.

 -> Fixes in drawing popultion (2D) function.
 -> Mid point calculations fixup.
 -> Reversed Cr fixup.
 -> de loop cleanups.