Move lock and unlock to CellRef (removes duplicate code)