Add free and alloc functions for global state