Added some better exceptions to some functions