Improved style, indentation and comments of code