Add a lot more type checking