Make Database a core module, upgrade to PDO, fix warnings