Fixed problem with changing edge directions