Cleaned up the source files a bit and added a ton of comments