added optimal triangulation. removed excess code and added a few util functions

Change-Id: Iada1287c82ab7fa6d5837175558ee20168d81c09