Database.php: better caching
Currently only the mysqli handle is cached but the Database object is recreated often.
- switch to singleton pattern for Database class (call Database::getInstance() instead of new Database)
- make Database a static class (?)
Both changes need a lot of refactoring.