Various small fixes and improvements