Bug fixes and security fix