Fixed bug for multi-token types

Also some minor cleanup and a new test, Euler problem 6.