many fixes and security improvements