Code cleanup

Added comments and adjust spacing and indentations.