Added comments and some formatting