fixed crash. Started work on ensuring lock_state is respected.