Database Refactor, XML, Debug

Query and MySQLDatabase Refactor.