General cleanup and added comments