Implements 'apply patch'