Cleanup

Clean up the code and add a couple of comments