Several bug fixes and code smell fixes

* Fix bug causing multiple version records to be saved into the
  database meta info
* Harden select query in DBManager.get_sum
* Create an empty sums file on the remote if it doesn't exist yet
* Resolve warnings about redefining built-ins
* Resolve a few minor code smells