Made cosmetic improvements and added comments for documentation.