Improve type checking
Improve type handling