Most of the GP modules can be pulled out of the loop here. This avoids re-allocating them all the time