lots of tweaks and fixes