cleanup and refactor halfway done. Some nice touches before grading