Cleaned up triangle code