Better lock handling in onActiveChange