Cleaned up code somewhat, started migration from deprecated libav.