Added prod, totient. Minor refactoring