Added comments and documentation