Cleaned up code for project phase three.