Add a bit more type checking