Fixed bug in triangulation code