Removed buggy edge detection and thinning functions