minor bug fixing and improvements