various code tweaks