g2: add proper TWRP support and optimizations

Change-Id: I6a2549c933d6f88f168ce2ec4e7c4ea2d9181697