Lots of tweaks and improvements