Removed obsolete code, improved security, refactored code