Minor changes, cleaned up code, fixed drawing bug.

Sorry to say that the flickering is still there.