code refactoring part 1

improved readability, started commenting stuff, removed unnecesseary
whitespaces