Cleaned up the structure of the program and fixed a rectangle positioning bug