Reorganized some code. Fixed the rect-object so that it only uses half the memory.