Minor code cleanup in post-comp 2014.1c.b

Add support for modulo arithmetic. Make factorial function
tail-recursive. Replace a Map with a Set for semantic precision.