Moved some things around to be more consistent, added caching to gateway.