Many tweaks and improvements