Added some additional comments and cleanup logic