Make some convoluted type inference to handle different cases differently