Miscellaneous fixes.

 - Fix SQL for retrieving accounting data.
 - Handle NONE value in accounting PETaskID
 - Add method to retrieve job request.
 - Add DB.Close() method.