Continued work on #9. Cleaned up a lot of bad code