Fixed the db.php and cleaned up the code