begins refactor to mongo. Beware all ye who tread here.