Wrote some graphics code and tests for it.
Also refactored some code.