WIP: Initial AbstractGateway refactoring

Please don't merge this yet. :)

It's the initial part of the gateway refactoring - more work is needed, but I am away this week and wanted to share my work for review, instead of letting it sit.

Updating this soon.