Cleaned up some code, and made it ready for submission