General bug fixing and improvements