Wip cleanup globals

This is the rebased version of https://github.com/ceph/ceph/pull/551.