Misc fixes

Notice that the percent notation scanning is not accurate, since it doesn't support nesting. e.g.

%(foo (bar) baz)