rewrote precedence table, misc refactoring