Improve type management