add bug fixes and improvements