Improved variable typing for locking