code cleaning and other tweaks