Improve type mapping and make almost the code to compile again