Added comments and fixes braces, indention problems