Refactored additional functions to use PDO. Source formatting and cleanup.
Refactored count query to use DB::Count function. Source formatting and cleanup.
Refactored count query to use DB::Count function. Source formatting and cleanup.