Initial code.
Rect painting improved.