Added comments and refactored code for better readability
Merge pull request #263 from jansoe/comments

Added comments and refactored code for better readability