rewrite to use numbers instead of symbols

also other little changes, and some comments