Partially resolved issue 213.

The resolving speed is acceptable now, but `processDeclarations` still
get called too many times.
And I don't know how to write a test case to measure speed.
Merge pull request #214 from coocood/master

Partially resolved issue 213