Add function to retrieve a single row from the DB.

Also did some additional code cleanup.