Removed all debug code and added back the security checks