better type inference for AutoKeyField and expressions classes refactoring