Implemented MySQLi and did a general cleanup.