Cleaned up a few things, and added comments