Locking and miscellaneous changes