Converted class Device to PDO calls with error logging.  Some functions that call other classes still must include the $db parameter until we're finished.

#164