pulled out meta-gui initialization
put most of the state at the top
cleaned up arguments
scoping out some stack allocations
got rid of unused header file