some bug fixes and comments