Updated syntax for triangle counting and added in some optimizations.