Fixed some issues that made this not play nice with newer opencv versions