lots of small fixes, tweaks, cleanup