Several Bug Fixes and improvements