more robust class identification in AST