Fixed edge deetection bug

Because of the new drawing system I had to change the way edges are
detected.