Added some comments and cleanup