Added comments and code clean up