more refactoring of gAPI for legibility and modularity