wouldn't it be better if all this were in a class rather than a namespace with free-standing functions? that's a LOT of globals to have.