Copy of AAPS_A code as template for AAPS_G.