Refactored gateway section, added unregister, unregister_all and switch to commands.