refactoring to do things a little more nginx-like.