clean up math functionality; make pie plot more useful