Improve performance of lock/synchronize patches

Signed-off-by: Ross Allan <rallanpcl@gmail.com>