Adaptations & refactoring
 - Better cleanup
 - Adapted to https://github.com/ayberkozgur/opencv/tree/issue3925
 - Retab