more bug fixes
added comments and documentation
more bug fixes