A few tweaks to edge detection
Moderately big reorg