Major revision to type inference mechanism

Somehow, printing things is broken, though