general gateway refactoring to cope with pikelet changes, WIP