Compiling clean up
Modifications to state and added global state