Move global var to top
Add the class attribute test
Properly infer bases