Code cleanup

This is the first of several patches to attempt to cleanup and clarify the ZeroCloud code. Test coverage is quite good, so this sort of refactoring should be easy to do with confidence.