Engine API improvements

Addresses https://bugs.launchpad.net/oq-engine/+bug/1199852

https://github.com/gem/oq-engine/pull/1226, https://github.com/gem/oq-engine/pull/1227, and https://github.com/gem/oq-engine/pull/1228 should merge first for a clean diff.