Updated to deal with locking slightly better, maybe