diff --git a/cinelerra-5.1/Makefile.devel b/cinelerra-5.1/Makefile.devel
index 55313308..ad671f57 100644
--- a/cinelerra-5.1/Makefile.devel
+++ b/cinelerra-5.1/Makefile.devel
@@ -4,7 +4,7 @@ TOPDIR := $(CURDIR)
 CFLAGS ?= -ggdb
 export CFLAGS_ := $(CFLAGS)
 
-cpus:=$(shell grep -c "^proc" /proc/cpuinfo)
+cpus:=$(shell sysctl -n hw.ncpu)
 jobs:=-j$(shell echo $$(($(cpus) + $(cpus)/2 +2)))
 MAKEJ := $(MAKE) $(jobs)
 
diff --git a/cinelerra-5.1/blds/bsd.bld b/cinelerra-5.1/blds/bsd.bld
index 165cc00b..aa6b98cc 100755
--- a/cinelerra-5.1/blds/bsd.bld
+++ b/cinelerra-5.1/blds/bsd.bld
@@ -1,19 +1,19 @@
-#!/bin/bash
+#!/usr/local/bin/bash
 #use: patch -p2 < bsd.patch
 export CONFIG_SHELL=/bin/bash
 export MAKE=gmake
 export C_INCLUDE_PATH=/usr/local/include
-export CPLUS_INCLUDE_PATH=/usr/local/include
+export CPLUS_INCLUDE_PATH=/usr/local/include/a52dec:/usr/local/include:/usr/local/include/OpenEXR:/usr/local/include/Imath
 export LIBRARY_PATH=/usr/local/lib
 alias make=gmake
 ( ./autogen.sh
-  BSD=1 CC=clang CXX=clang++ CFLAGS="-g -O2 -DFFMPEG3" \
+  BSD=1 CC=clang CXX=clang++ CFLAGS="-g -O2 " \
   ./configure --with-single-user \
-    --disable-static-build --without-lv2 --disable-lame --disable-twolame \
-    --with-oss --without-alsa --without-firewire --without-dv --without-dvb \
-    --without-video4linux2 --without-xxf86vm --without-ladspa-build \
-    --without-libzmpeg --without-commercial --without-thirdparty \
-    --without-vaapi --without-vdpau --without-shuttle --without-shuttle-usb \
-    --without-x10tv --without-wintv
+    --disable-static-build  --without-libzmpeg --without-dvb \
+    --with-oss --without-libdpx --without-alsa --without-firewire --without-dv --without-video4linux2 \
+     --without-xxf86vm --without-ladspa-build \
+     --without-commercial --without-thirdparty \
+     --without-shuttle --without-shuttle-usb \
+    --without-x10tv --with-jobs=4 --without-wintv
    gmake
    gmake install ) 2>&1 | tee log
diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
index 65df2f4a..a8ab8d3d 100644
--- a/cinelerra-5.1/cinelerra/Makefile
+++ b/cinelerra-5.1/cinelerra/Makefile
@@ -438,7 +438,7 @@ LIBS += -lavcodec -lavdevice -lavfilter -lavformat -lavutil
 LIBS += -lswresample -lswscale
 LIBS += -lintl -liconv
 LIBS += -lexecinfo
-
+LIBS += `pkg-config --libs OpenEXR`
 LIBS += $(shared_libs)
 LIBS += $(system_libs)
 else
@@ -518,7 +518,7 @@ all:	$(OUTPUT) $(CUTADS) $(BDWRITE) $(LV2UI)
 $(OUTPUT): $(OBJS) $(THEME_DATA) $(DCRAW) $(LIBRARIES)
 	$(LINKER) `cat $(OBJDIR)/objs`
 	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(OUTPUT) $(OUTPUT_G))
-	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
+	#$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
 	ln -f -s ../bin/$(WANT_CIN) ci
 
 ifneq ($(WANT_COMMERCIAL),no)
diff --git a/cinelerra-5.1/cinelerra/bdcreate.C b/cinelerra-5.1/cinelerra/bdcreate.C
index 150f835d..7df25e77 100644
--- a/cinelerra-5.1/cinelerra/bdcreate.C
+++ b/cinelerra-5.1/cinelerra/bdcreate.C
@@ -24,8 +24,8 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
+#include <sys/param.h>
+#include <sys/mount.h>
 
 // BD Creation
 
diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
index 6a2b4ca3..78cf9bef 100644
--- a/cinelerra-5.1/cinelerra/bdwrite.C
+++ b/cinelerra-5.1/cinelerra/bdwrite.C
@@ -38,7 +38,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <endian.h>
+#include <sys/endian.h>
 #include <limits.h>
 #include <sys/stat.h>
 // work arounds (centos)
diff --git a/cinelerra-5.1/cinelerra/ci b/cinelerra-5.1/cinelerra/ci
index bc987833..22858982 120000
--- a/cinelerra-5.1/cinelerra/ci
+++ b/cinelerra-5.1/cinelerra/ci
@@ -1 +1 @@
-../bin/cinelerra
\ No newline at end of file
+../bin/cin
\ No newline at end of file
diff --git a/cinelerra-5.1/cinelerra/cutads.C b/cinelerra-5.1/cinelerra/cutads.C
index ac58d56a..f6690cf2 100644
--- a/cinelerra-5.1/cinelerra/cutads.C
+++ b/cinelerra-5.1/cinelerra/cutads.C
@@ -23,14 +23,6 @@
 using namespace std;
 #define fail(s) do { printf("fail %s%s:%d\n",__func__,#s,__LINE__); return 1; } while(0)
 
-/* missing from system headers, no /usr/include <linux/ioprio.h>
- *   IOPRIO_WHO_PROCESS, IOPRIO_CLASS_SHIFT, IOPRIO_CLASS_IDLE */
-enum { IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE, };
-#define IO_CLASS(n) (((int)(n)) << 13)
-#define IO_WHO_PROCESS  1
-#include <sys/syscall.h>
-#include <asm/unistd.h>
-
 // commercial edge detection:
 // must have audio < min_audio
 //   and within +- check_margin seconds of low audio
@@ -55,11 +47,6 @@ class Video;
 class Audio;
 class Scan;
 
-static int ioprio_set(int which, int who, int ioprio)
-{
-	return syscall(SYS_ioprio_set, which, who, ioprio);
-}
-
 static inline int clip(int v, int mn, int mx)
 {
   return v<mn ? mn : v>mx ? mx : v;
@@ -617,7 +604,6 @@ class Scan
 	const char *asset_path;
 	static void set_priority(int pr, int io) {
 		setpriority(PRIO_PROCESS, 0, pr);  // lowest cpu priority
-		ioprio_set(IO_WHO_PROCESS, 0, IO_CLASS(io));
 	}
 	class low_priority { public:
 		low_priority() { set_priority(19, IOPRIO_CLASS_IDLE); }
diff --git a/cinelerra-5.1/cinelerra/dvdcreate.C b/cinelerra-5.1/cinelerra/dvdcreate.C
index 6ecb270b..4f25daae 100644
--- a/cinelerra-5.1/cinelerra/dvdcreate.C
+++ b/cinelerra-5.1/cinelerra/dvdcreate.C
@@ -24,8 +24,8 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <sys/stat.h>
-#include <sys/statfs.h>
+#include <sys/param.h>
+#include <sys/mount.h>
 
 
 #define DVD_PAL_4x3	0
diff --git a/cinelerra-5.1/cinelerra/exportedl.C b/cinelerra-5.1/cinelerra/exportedl.C
index cac86bcf..776690bd 100644
--- a/cinelerra-5.1/cinelerra/exportedl.C
+++ b/cinelerra-5.1/cinelerra/exportedl.C
@@ -40,6 +40,7 @@
 #include "tracks.h"
 #include "transition.h"
 
+#include <libgen.h>
 #include <ctype.h>
 #include <string.h>
 
diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C
index 32020574..684111c6 100644
--- a/cinelerra-5.1/cinelerra/file.C
+++ b/cinelerra-5.1/cinelerra/file.C
@@ -1666,7 +1666,10 @@ int File::record_fd()
 void File::get_exe_path(char *result, char *bnp)
 {
 // Get executable path, basename
-	int len = readlink("/proc/self/exe", result, BCTEXTLEN-1);
+	char exe_path[BCTEXTLEN];
+	sprintf(exe_path,"/proc/%d/file",getpid());
+	int len = readlink(exe_path, result, BCTEXTLEN-1);
+
 	if( len >= 0 ) {
 		result[len] = 0;
 		char *ptr = strrchr(result, '/');
diff --git a/cinelerra-5.1/cinelerra/fileexr.C b/cinelerra-5.1/cinelerra/fileexr.C
index 9c782a11..fbc39862 100644
--- a/cinelerra-5.1/cinelerra/fileexr.C
+++ b/cinelerra-5.1/cinelerra/fileexr.C
@@ -50,8 +50,8 @@ public:
 	~EXRIStream();
 
 	bool read (char c[], int n);
-	Imf::Int64 tellg ();
-	void seekg (Imf::Int64 pos);
+	uint64_t tellg ();
+	void seekg (uint64_t pos);
 	void clear ();
 
 private:
@@ -67,8 +67,8 @@ public:
 	~EXROStream();
 
     virtual void write(const char c[], int n);
-    virtual Imf::Int64 tellp();
-    virtual void seekp(Imf::Int64 pos);
+    virtual uint64_t tellp();
+    virtual void seekp(uint64_t pos);
 
 private:
 	VFrame *data;
@@ -106,12 +106,12 @@ bool EXRIStream::read(char c[], int n)
 	return position >= size;
 }
 
-Imf::Int64 EXRIStream::tellg ()
+uint64_t EXRIStream::tellg ()
 {
 	return position;
 }
 
-void EXRIStream::seekg(Imf::Int64 pos)
+void EXRIStream::seekg(uint64_t pos)
 {
 	position = pos;
 }
@@ -141,12 +141,12 @@ void EXROStream::write(const char c[], int n)
 	data->set_compressed_size(MAX(position, data->get_compressed_size()));
 }
 
-Imf::Int64 EXROStream::tellp()
+uint64_t EXROStream::tellp()
 {
 	return position;
 }
 
-void EXROStream::seekp(Imf::Int64 pos)
+void EXROStream::seekp(uint64_t pos)
 {
 	position = pos;
 }
diff --git a/cinelerra-5.1/cinelerra/filegif.C b/cinelerra-5.1/cinelerra/filegif.C
index 88c4eb90..95f11e95 100644
--- a/cinelerra-5.1/cinelerra/filegif.C
+++ b/cinelerra-5.1/cinelerra/filegif.C
@@ -35,12 +35,13 @@
 
 //from "getarg.h"
 extern "C"
+/*
 int GifQuantizeBuffer(unsigned int Width, unsigned int Height,
                    int *ColorMapSize, GifByteType * RedInput,
                    GifByteType * GreenInput, GifByteType * BlueInput,
                    GifByteType * OutputBuffer,
                    GifColorType * OutputColorMap);
-
+*/
 FileGIF::FileGIF(Asset *asset, File *file)
  : FileBase(asset, file)
 {
@@ -367,9 +368,9 @@ int FileGIF::write_frame(VFrame *frame)
 			GifByteType *gp = (GifByteType *)gbrp.get_r();
 			GifByteType *bp = (GifByteType *)gbrp.get_g();
 			GifByteType *rp = (GifByteType *)gbrp.get_b();
-			if( GifQuantizeBuffer(w, h, &cmap_sz, rp, gp, bp,
+			/* if( GifQuantizeBuffer(w, h, &cmap_sz, rp, gp, bp,
 					bfr, cmap->Colors) == GIF_ERROR )
-				result = 1;
+				result = 1; */
 		}
 	}
 	if( !result && !writes &&
diff --git a/cinelerra-5.1/cinelerra/indexfile.C b/cinelerra-5.1/cinelerra/indexfile.C
index 977ad1cb..29a93ad0 100644
--- a/cinelerra-5.1/cinelerra/indexfile.C
+++ b/cinelerra-5.1/cinelerra/indexfile.C
@@ -70,9 +70,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_ISOFS
-#include <linux/iso_fs.h>
-#endif
+#include <isofs/cd9660/iso.h>
 
 // check for isofs volume_id for dvd/cdrom
 
diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac
index e83d4666..f92d27cd 100644
--- a/cinelerra-5.1/configure.ac
+++ b/cinelerra-5.1/configure.ac
@@ -22,8 +22,18 @@ CFG_CFLAGS+=" -Wno-unused-result"
 CFG_CFLAGS+=" -Wno-stringop-overflow"
 CFG_CFLAGS+=" -Wno-format-truncation"
 CFG_CFLAGS+=" -Wno-format-overflow"
+CFG_CFLAGS+=" -Wno-unknown-warning-option"
 CFG_CFLAGS+=" -Wno-parentheses"
 CFG_CFLAGS+=" -Wno-stringop-truncation"
+CFG_CFLAGS+=" -Wno-gnu-designator"
+CFG_CFLAGS+=" -Wno-missing-braces"
+CFG_CFLAGS+=" -Wno-overloaded-virtual"
+CFG_CFLAGS+=" -Wno-self-assign-field"
+CFG_CFLAGS+=" -Wno-sometimes-uninitialized"
+CFG_CFLAGS+=" -Wno-tautological-pointer-compare"
+CFG_CFLAGS+=" -Wno-unused-function"
+CFG_CFLAGS+=" -Wno-unused-private-field"
+CFG_CFLAGS+=" -Wno-infinite-recursion"
 CFG_CFLAGS+=" -D__STDC_CONSTANT_MACROS"
 CFG_CFLAGS+=" -D__STDC_LIMIT_MACROS"
 CFG_CFLAGS+=" -DPNG_SKIP_SETJMP_CHECK=1"
@@ -1186,6 +1196,11 @@ if test "x$CFG_LDFLAGS" != "x" ; then
   echo ""
 fi
 
+if test "x$BSD" != "x" ; then
+  echo "CFLAGS += -DNO_PRCTL"
+  echo "CFLAGS += -DNO_TID"
+  echo "CFLAGS += -DNO_GDB"
+fi
 if test "x$CYGWIN" != "x" ; then
   echo 'FF_PATH ?= /usr/local'
   echo 'LDFLAGS += -L$(FF_PATH)/lib'
@@ -1201,11 +1216,6 @@ if test "x$CYGWIN" != "x" ; then
 else
   LDFLAGS+=" -z noexecstack"
 fi
-if test "x$BSD" != "x" ; then
-  echo "CFLAGS += -DNO_PRCTL"
-  echo "CFLAGS += -DNO_TID"
-  echo "CFLAGS += -DNO_GDB"
-fi
 
 if test "x$WANT_X264_HIDEPTH" = "xyes" ; then
   X264_CFG_PARAMS="$X264_CFG_PARAMS --bit-depth=10"
diff --git a/cinelerra-5.1/db/tdb.h b/cinelerra-5.1/db/tdb.h
index 24c8617c..74881ff0 100644
--- a/cinelerra-5.1/db/tdb.h
+++ b/cinelerra-5.1/db/tdb.h
@@ -33,7 +33,7 @@ inline void operator delete[](void *t,size_t n) { free(t); }
 #endif
 
 #define ZMEDIA
-#define ZFUTEX
+//#define ZFUTEX
 #ifdef ZFUTEX
 #include <unistd.h>
 #include <endian.h>
diff --git a/cinelerra-5.1/guicast/Makefile b/cinelerra-5.1/guicast/Makefile
index de3f5172..aa20dc54 100644
--- a/cinelerra-5.1/guicast/Makefile
+++ b/cinelerra-5.1/guicast/Makefile
@@ -118,8 +118,10 @@ $(shell echo $(OBJS) > $(OBJDIR)/objs)
 
 all: $(OUTPUT) $(UTILS)
 
+python = $(shell find /usr/local/bin -name python3\* | head -n 1)
+
 $(BCXFER):	bccmdl.py bcxfer.C bcxfer.h
-	python < ./bccmdl.py
+	$(python) < ./bccmdl.py
 	+$(MAKE) -C xfer
 
 $(OUTPUT): $(OBJS) $(BCXFER)
@@ -133,7 +135,7 @@ $(OBJDIR)/pngtoh: pngtoh.c
 	$(CC) -O2 pngtoh.c -o $(OBJDIR)/pngtoh
 
 $(OBJDIR)/pngtoraw: pngtoraw.c
-	$(CC) -O2 pngtoraw.c -o $(OBJDIR)/pngtoraw -lpng -lz
+	$(CC) -O2 pngtoraw.c -o $(OBJDIR)/pngtoraw `pkg-config --libs libpng` `pkg-config -cflags libpng` -lz
 
 clean:
 	rm -rf $(OBJDIR)
diff --git a/cinelerra-5.1/guicast/bclistbox.h b/cinelerra-5.1/guicast/bclistbox.h
index ce34ffc4..0e38913d 100644
--- a/cinelerra-5.1/guicast/bclistbox.h
+++ b/cinelerra-5.1/guicast/bclistbox.h
@@ -187,7 +187,9 @@ public:
 
 // take_focus - used by the suggestion box to keep it from taking focus from the
 // textbox
-	int activate(int take_focus = 1);
+	int activate() {  return activate(1); }
+	int activate(int take_focus);
+
 	int activate(int x, int y, int w=-1, int h=-1);
 	int deactivate();
 	int is_active();
diff --git a/cinelerra-5.1/guicast/bcpan.h b/cinelerra-5.1/guicast/bcpan.h
index 40f5971f..73d47586 100644
--- a/cinelerra-5.1/guicast/bcpan.h
+++ b/cinelerra-5.1/guicast/bcpan.h
@@ -93,7 +93,8 @@ public:
 		int &stick_x,
 		int &stick_y);
 	static int rdtoxy(int &x, int &y, int a, int virtual_r);
-	int activate(int popup_x = -1, int popup_y = -1);
+	int activate(int popup_x, int popup_y);
+	int activate() { return activate(-1,-1); }
 	int deactivate();
 	float* get_values();
 
diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C
index cdac6305..de912dd1 100644
--- a/cinelerra-5.1/guicast/bcresources.C
+++ b/cinelerra-5.1/guicast/bcresources.C
@@ -39,6 +39,7 @@
 #include <iconv.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#include <sys/sysctl.h>
 #include <X11/extensions/XShm.h>
 #include <fontconfig/fontconfig.h>
 #include <fontconfig/fcfreetype.h>
@@ -298,23 +299,12 @@ int BC_Resources::machine_cpus = 1;
 
 int BC_Resources::get_machine_cpus()
 {
-	int cpus = 1;
-	FILE *proc = fopen("/proc/cpuinfo", "r");
-	if( proc ) {
-		char string[BCTEXTLEN], *cp;
-		while(!feof(proc) && fgets(string, sizeof(string), proc) ) {
-			if( !strncasecmp(string, "processor", 9) &&
-			    (cp = strchr(string, ':')) != 0 ) {
-				int n = atol(cp+1) + 1;
-				if( n > cpus ) cpus = n;
-			}
-			else if( !strncasecmp(string, "cpus detected", 13) &&
-			    (cp = strchr(string, ':')) != 0 )
-				cpus = atol(cp+1);
-		}
-		fclose(proc);
-	}
-	return cpus;
+	int mib[2], ncpu;
+	size_t len = sizeof(ncpu);
+	mib[0] = CTL_HW;
+	mib[1] = HW_NCPU;
+	if( sysctl(mib, 2, &ncpu, &len, 0, 0) ) ncpu = 1;
+	return ncpu;
 }
 
 void BC_Resources::new_vframes(int n, VFrame *vframes[], ...)
@@ -367,8 +357,8 @@ BC_Resources::BC_Resources(float x_scale, float y_scale)
 	BC_WindowBase::resources = this;
 	synchronous = 0;
 	vframe_shm = 0;
-	use_shm = -1;
-	shm_reply = 1;
+	use_shm = 0;
+	shm_reply = 0;
 
 	if( x_scale <= 0 ) x_scale = 1;
 	if( y_scale <= 0 ) y_scale = x_scale;
diff --git a/cinelerra-5.1/guicast/bcsignals.C b/cinelerra-5.1/guicast/bcsignals.C
index 858ba409..ae9cf698 100644
--- a/cinelerra-5.1/guicast/bcsignals.C
+++ b/cinelerra-5.1/guicast/bcsignals.C
@@ -403,70 +403,72 @@ const char* BC_Signals::sig_to_str(int number)
 #include <sys/wait.h>
 #include "thread.h"
 
+#define SC_(r)mc_##r
+
 #if __i386__
-#define IP eip
-#define sigregs_t sigcontext
+#define IP SC_(eip)
+#define sigregs_t mcontext_t
 
 static void reg_dump(FILE *fp,sigregs_t *rp)
 {
 	fprintf(fp,"REGS:\n");
-	fprintf(fp,"  gs: %04x:%04x\n", rp->gs,rp->__gsh);
-	fprintf(fp,"  fs: %04x:%04x\n", rp->fs,rp->__fsh);
-	fprintf(fp,"  es: %04x:%04x\n", rp->es,rp->__esh);
-	fprintf(fp,"  ds: %04x:%04x\n", rp->ds,rp->__dsh);
-	fprintf(fp," edi: %14p %d\n", (void*)rp->edi,rp->edi);
-	fprintf(fp," esi: %14p %d\n", (void*)rp->esi,rp->esi);
-	fprintf(fp," ebp: %14p %d\n", (void*)rp->ebp,rp->ebp);
-	fprintf(fp," esp: %14p %d\n", (void*)rp->esp,rp->esp);
-	fprintf(fp," ebx: %14p %d\n", (void*)rp->ebx,rp->ebx);
-	fprintf(fp," edx: %14p %d\n", (void*)rp->edx,rp->edx);
-	fprintf(fp," ecx: %14p %d\n", (void*)rp->ecx,rp->ecx);
-	fprintf(fp," eax: %14p %d\n", (void*)rp->eax,rp->eax);
-	fprintf(fp," trapno: %14p %d\n", (void*)rp->trapno,rp->trapno);
-	fprintf(fp," err: %14p %d\n", (void*)rp->err,rp->err);
-	fprintf(fp," eip: %14p %d\n", (void*)rp->eip,rp->eip);
-	fprintf(fp," cs: %04xd : %04x\n", rp->cs,rp->__csh);
-	fprintf(fp," eflags: %14p %d\n", (void*)rp->eflags,rp->eflags);
-	fprintf(fp," esp_at_signal: %p %d\n", (void*)rp->esp_at_signal,rp->esp_at_signal);
-	fprintf(fp," ss: %04xd : %04x\n", rp->ss,rp->__ssh);
-	fprintf(fp," oldmask: %14p %d\n", (void*)rp->oldmask,rp->oldmask);
-	fprintf(fp," cr2: %14p %d\n", (void*)rp->cr2,rp->cr2);
+	fprintf(fp,"  gs: %04x:%04x\n", rp->mc_gs,rp->mc_gs);
+	fprintf(fp,"  fs: %04x:%04x\n", rp->mc_fs,rp->mc_fs);
+	fprintf(fp,"  es: %04x:%04x\n", rp->mc_es,rp->mc_es);
+	fprintf(fp,"  ds: %04x:%04x\n", rp->mc_ds,rp->mc_ds);
+	fprintf(fp," edi: %14p %d\n", (void*)rp->mc_edi,rp->mc_edi);
+	fprintf(fp," esi: %14p %d\n", (void*)rp->mc_esi,rp->mc_esi);
+	fprintf(fp," ebp: %14p %d\n", (void*)rp->mc_ebp,rp->mc_ebp);
+	fprintf(fp," esp: %14p %d\n", (void*)rp->mc_esp,rp->mc_esp);
+	fprintf(fp," ebx: %14p %d\n", (void*)rp->mc_ebx,rp->mc_ebx);
+	fprintf(fp," edx: %14p %d\n", (void*)rp->mc_edx,rp->mc_edx);
+	fprintf(fp," ecx: %14p %d\n", (void*)rp->mc_ecx,rp->mc_ecx);
+	fprintf(fp," eax: %14p %d\n", (void*)rp->mc_eax,rp->mc_eax);
+	fprintf(fp," trapno: %14p %d\n", (void*)rp->mc_trapno,rp->mc_trapno);
+	fprintf(fp," err: %14p %d\n", (void*)rp->mc_err,rp->mc_err);
+	fprintf(fp," eip: %14p %d\n", (void*)rp->mc_eip,rp->mc_eip);
+	fprintf(fp," cs: %04x\n", (unsigned)rp->mc_cs);
+	fprintf(fp," eflags: %14p %d\n", (void*)rp->mc_eflags,rp->mc_eflags);
+	fprintf(fp," esp_at_signal: %p %d\n", (void*)rp->mc_esp_at_signal,rp->mc_esp_at_signal);
+	fprintf(fp," ss: %04xd : %04x\n", rp->mc_ss,rp->mc_ss);
+//	fprintf(fp," oldmask: %14p %d\n", (void*)rp->mc_oldmask,rp->mc_oldmask);
+//	fprintf(fp," cr2: %14p %d\n", (void*)rp->mc_cr2,rp->mc_cr2);
 	fprintf(fp,"\n");
 }
 #endif
 
 #if __x86_64__
-#define IP rip
-#define sigregs_t sigcontext
+#define IP SC_(rip)
+#define sigregs_t mcontext_t
 
 static void reg_dump(FILE *fp,sigregs_t *rp)
 {
 	fprintf(fp,"REGS:\n");
-	fprintf(fp,"  r8: %20p %jd\n", (void*)rp->r8,rp->r8);
-	fprintf(fp,"  r9: %20p %jd\n", (void*)rp->r9,rp->r9);
-	fprintf(fp," r10: %20p %jd\n", (void*)rp->r10,rp->r10);
-	fprintf(fp," r11: %20p %jd\n", (void*)rp->r11,rp->r11);
-	fprintf(fp," r12: %20p %jd\n", (void*)rp->r12,rp->r12);
-	fprintf(fp," r13: %20p %jd\n", (void*)rp->r13,rp->r13);
-	fprintf(fp," r14: %20p %jd\n", (void*)rp->r14,rp->r14);
-	fprintf(fp," r15: %20p %jd\n", (void*)rp->r15,rp->r15);
-	fprintf(fp," rdi: %20p %jd\n", (void*)rp->rdi,rp->rdi);
-	fprintf(fp," rsi: %20p %jd\n", (void*)rp->rsi,rp->rsi);
-	fprintf(fp," rbp: %20p %jd\n", (void*)rp->rbp,rp->rbp);
-	fprintf(fp," rbx: %20p %jd\n", (void*)rp->rbx,rp->rbx);
-	fprintf(fp," rdx: %20p %jd\n", (void*)rp->rdx,rp->rdx);
-	fprintf(fp," rax: %20p %jd\n", (void*)rp->rax,rp->rax);
-	fprintf(fp," rcx: %20p %jd\n", (void*)rp->rcx,rp->rcx);
-	fprintf(fp," rsp: %20p %jd\n", (void*)rp->rsp,rp->rsp);
-	fprintf(fp," rip: %20p %jd\n", (void*)rp->rip,rp->rip);
-	fprintf(fp," eflags: %14p %jd\n", (void*)rp->eflags,rp->eflags);
-	fprintf(fp,"  cs: %04x\n", rp->cs);
-	fprintf(fp,"  gs: %04x\n", rp->gs);
-	fprintf(fp,"  fs: %04x\n", rp->fs);
-	fprintf(fp," err: %20p %jd\n", (void*)rp->err,rp->err);
-	fprintf(fp," trapno: %20p %jd\n", (void*)rp->trapno,rp->trapno);
-	fprintf(fp," oldmask: %20p %jd\n", (void*)rp->oldmask,rp->oldmask);
-	fprintf(fp," cr2: %20p %jd\n", (void*)rp->cr2,rp->cr2);
+	fprintf(fp,"  r8: %20p %jd\n", (void*)rp->mc_r8,rp->mc_r8);
+	fprintf(fp,"  r9: %20p %jd\n", (void*)rp->mc_r9,rp->mc_r9);
+	fprintf(fp," r10: %20p %jd\n", (void*)rp->mc_r10,rp->mc_r10);
+	fprintf(fp," r11: %20p %jd\n", (void*)rp->mc_r11,rp->mc_r11);
+	fprintf(fp," r12: %20p %jd\n", (void*)rp->mc_r12,rp->mc_r12);
+	fprintf(fp," r13: %20p %jd\n", (void*)rp->mc_r13,rp->mc_r13);
+	fprintf(fp," r14: %20p %jd\n", (void*)rp->mc_r14,rp->mc_r14);
+	fprintf(fp," r15: %20p %jd\n", (void*)rp->mc_r15,rp->mc_r15);
+	fprintf(fp," rdi: %20p %jd\n", (void*)rp->mc_rdi,rp->mc_rdi);
+	fprintf(fp," rsi: %20p %jd\n", (void*)rp->mc_rsi,rp->mc_rsi);
+	fprintf(fp," rbp: %20p %jd\n", (void*)rp->mc_rbp,rp->mc_rbp);
+	fprintf(fp," rbx: %20p %jd\n", (void*)rp->mc_rbx,rp->mc_rbx);
+	fprintf(fp," rdx: %20p %jd\n", (void*)rp->mc_rdx,rp->mc_rdx);
+	fprintf(fp," rax: %20p %jd\n", (void*)rp->mc_rax,rp->mc_rax);
+	fprintf(fp," rcx: %20p %jd\n", (void*)rp->mc_rcx,rp->mc_rcx);
+	fprintf(fp," rsp: %20p %jd\n", (void*)rp->mc_rsp,rp->mc_rsp);
+	fprintf(fp," rip: %20p %jd\n", (void*)rp->mc_rip,rp->mc_rip);
+	fprintf(fp," eflags: %14p %u\n", (void*)((unsigned long)rp->mc_flags),rp->mc_flags);
+	fprintf(fp,"  cs: %04x\n", (unsigned)rp->mc_cs);
+	fprintf(fp,"  gs: %04x\n", (unsigned)rp->mc_gs);
+	fprintf(fp,"  fs: %04x\n", (unsigned)rp->mc_fs);
+	fprintf(fp," err: %20p %jd\n", (void*)rp->mc_err,rp->mc_err);
+	fprintf(fp," trapno: %20p %d\n", (void*)((unsigned long)rp->mc_trapno),rp->mc_trapno);
+//	fprintf(fp," oldmask: %20p %jd\n", (void*)rp->mc_oldmask,rp->mc_oldmask);
+//	fprintf(fp," cr2: %20p %jd\n", (void*)rp->mc_cr2,rp->mc_cr2);
 	fprintf(fp,"\n");
 }
 
@@ -500,7 +502,7 @@ static void handle_dump(int n, siginfo_t * info, void *sc)
 	void *ip = 0;
 #ifndef NO_CTX
 	ucontext_t *uc = (ucontext_t *)sc;
-	struct sigregs_t *c = (struct sigregs_t *)&uc->uc_mcontext;
+	sigregs_t *c = (sigregs_t *)&uc->uc_mcontext;
 	ip = (void *)c->IP;
 #endif
 	fprintf(stderr,"** %s at %p in pid %d, tid %d\n",
diff --git a/cinelerra-5.1/guicast/bctrace.C b/cinelerra-5.1/guicast/bctrace.C
index 7e453925..2d08b46b 100644
--- a/cinelerra-5.1/guicast/bctrace.C
+++ b/cinelerra-5.1/guicast/bctrace.C
@@ -309,7 +309,7 @@ void BC_Trace::dump_traces(FILE *fp)
 	}
 }
 
-void trace_info::set_owner() { owner = pthread_self(); }
+void trace_info::set_owner() { owner = (unsigned long)pthread_self(); }
 void trace_info::unset_owner() { owner = 0; }
 
 void BC_Trace::dump_locks(FILE *fp)
@@ -322,7 +322,7 @@ void BC_Trace::dump_locks(FILE *fp)
 		fprintf(fp,"    %p %s, %s %p%s",
 			p->info, p->title, p->loc,
 			(void*)p->tid, p->is_owner ? " *" : "");
-		if( p->info->owner && p->info->owner != p->tid )
+		if( p->info->owner && p->info->owner != (unsigned long)p->tid )
 			fprintf(fp," %p", (void*)p->info->owner);
 		fprintf(fp,"\n");
 	}
diff --git a/cinelerra-5.1/guicast/filesystem.h b/cinelerra-5.1/guicast/filesystem.h
index c976135b..56137025 100644
--- a/cinelerra-5.1/guicast/filesystem.h
+++ b/cinelerra-5.1/guicast/filesystem.h
@@ -26,6 +26,9 @@
 #include "bcwindowbase.inc"
 #include "sizes.h"
 
+#define dirent64 dirent
+#define readdir64 readdir
+
 class FileItem
 {
 public:
diff --git a/cinelerra-5.1/guicast/thread.C b/cinelerra-5.1/guicast/thread.C
index 9908a628..768ca61d 100644
--- a/cinelerra-5.1/guicast/thread.C
+++ b/cinelerra-5.1/guicast/thread.C
@@ -58,13 +58,6 @@ void* Thread::entrypoint(void *parameters)
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
 	thread->cancel_enabled = false;
 
-// Set realtime here since it doesn't work in start
-	if( thread->realtime && getuid() == 0 ) {
-		struct sched_param param = { sched_priority : 1 };
-		if(pthread_setschedparam(thread->tid, SCHED_RR, &param) < 0)
-			perror("Thread::entrypoint pthread_attr_setschedpolicy");
-	}
-
 	thread->run();
 	thread->finished = true;
 	if( !thread->synchronous ) {
diff --git a/cinelerra-5.1/libzmpeg3/libzmpeg3.h b/cinelerra-5.1/libzmpeg3/libzmpeg3.h
index 8ea33b15..4b2eb500 100644
--- a/cinelerra-5.1/libzmpeg3/libzmpeg3.h
+++ b/cinelerra-5.1/libzmpeg3/libzmpeg3.h
@@ -6,8 +6,10 @@
 #define MAXFRAMESAMPLES 65536
 #define ZDVB
 #if defined(__i386__) || defined(__x86_64__)
+#ifndef __FreeBSD__
 #define USE_FUTEX
 #endif
+#endif
 
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
@@ -22,17 +24,17 @@ typedef int (*zcc_text_cb)(int sid, int id, int sfrm, int efrm, const char *txt)
 #ifdef __cplusplus
 #include <unistd.h>
 #include <stdlib.h>
-#include <byteswap.h>
+//#include <byteswap.h>
 #include <dirent.h>
 #include <fcntl.h>
 #include <string.h>
 #include <limits.h>
 #include <errno.h>
-#include <endian.h>
+#include <sys/endian.h>
 #include <signal.h>
 #include <pthread.h>
-#include <mntent.h>
-#include <linux/cdrom.h>
+//#include <mntent.h>
+//#include <linux/cdrom.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
diff --git a/cinelerra-5.1/plugins/Makefile b/cinelerra-5.1/plugins/Makefile
index c4a5fd43..546063bf 100644
--- a/cinelerra-5.1/plugins/Makefile
+++ b/cinelerra-5.1/plugins/Makefile
@@ -37,7 +37,6 @@ DIRS = $(OPENCV_OBJS) \
 	brightness \
 	burn \
 	C41 \
-	cdripper \
 	chorus \
 	chromakey \
 	chromakeyhsv \
@@ -161,9 +160,7 @@ DIRS = $(OPENCV_OBJS) \
 	yuvshift \
 	zoom \
 	zoomblur \
-	theme_blond \
 	theme_blond_cv \
-	theme_blue \
 	theme_blue_dot \
 	theme_bright \
 	theme_hulk \
@@ -173,6 +170,13 @@ DIRS = $(OPENCV_OBJS) \
 	theme_unflat \
 	theme_cakewalk \
 
+PLATFORM = $(shell uname -o)
+
+ifneq ($(PLATFORM), FreeBSD)
+
+$(DIRS) += theme_blond 	theme_blue cdripper
+endif
+
 # not maintained
 #	motion-cv \
 #	motion-hv \
@@ -183,6 +187,8 @@ DIRS = $(OPENCV_OBJS) \
 #	denoisemjpeg \
 # duplicate
 #	vocoder \
+# not in bsd
+#	cdripper \
 
 PLUGIN_DIR = $(BINDIR)/plugins
 DATA = $(PLUGIN_DIR)/fonts $(PLUGIN_DIR)/shapes $(PLUGIN_DIR)/scopes
diff --git a/cinelerra-5.1/plugins/titler/titler.C b/cinelerra-5.1/plugins/titler/titler.C
index 06fb7938..1a2e35fe 100644
--- a/cinelerra-5.1/plugins/titler/titler.C
+++ b/cinelerra-5.1/plugins/titler/titler.C
@@ -57,8 +57,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
-#include <endian.h>
-#include <byteswap.h>
+#include <sys/endian.h>
 #include <iconv.h>
 #include <sys/stat.h>
 #include <fontconfig/fontconfig.h>
