Performance improvements: delete log prints, clear contours array.