Added type checking and other stuff to function calls