clean up some hideous code (made more hideous because Mongo doesn't allow int keys)