Added comments and delete GlobalState pointer when finished processing
Added comments