Authenticate clean up and enhancement

* PSR-2 cleanups
* Enable the use of frontend access control
* Move from serialize()/unserialize() to json_encode()/json_decode() and keep backward compatibility
* Clean up database functionality slightly
* Remove unused private function