make nested lock calls work correctly