Security fixes and small enhancements