bug fixes.
bug fixes and improvements