many tweaks and fixes