WIP locking state machine

Commented out stuff that wasn’t building. Still getting some import
warnings that I’m ignoring for now.