Fixed bug of not traversing base classes correctly.