bug fixes and comments added