Bug fix and improvements.