tweaks and fixes

made multiple fixes and tweaks. Please read commit descriptions for more details