Move some common functions to operations_lib