added ProcessLock. Modified functions so that they can be used as a primitive wrapper or as a standalone function, but never as static methods.