Move state into it's own internal struct