security handling and other fixes #2290