Make autolock more configurable and race-free