Fixed some memory problems, corrected the triangularion routines, and general cleanup