Added stuff so we can use OpenCV engine.
Corrected median so it actually works.