Cleanups, modify function locks