switched all queries to PDO instead of mysql_*; optimized some queries