Documentation Updates

Cleaned up the code and added comments.