added comments and minor clean up