Use Dictionary instead of array
Add some helper methods for improved readability
Handle parentheses and left/right-associativity correctly
Run cleanup