This function only uses the state.marked member, so that should be pass in instead. This would save a a lot of dereferencing.