Small fixes and improvements to previous commit