cleaning up code, comments, bug fixes

cleaning up code, comments, bug fixes