Adding #math and #permute, fixing some minor bugs.