Cleaned up graphics code, and general clean up