Minor bug fixes and improvements
