Fix var type inference2

Giving it another try.
Sorry, this was code ported from some older files.