Moved Gateway class to separate file