Code slightly refactored+Comments

Code slightly refactored to follow camelCase for local variables. Also
added some comments for ambiguous parts. Thinking about CamelCase for
functions.