added simple token -> number conversion and fixed some bugs that came up