Code Clean

Added more comments to the code and restructured a bit.