improved error handling. some code clean up
improved error handling. some code clean up

cgranade/qutip,qutip/qutip,zasdfgbnm/qutip,anubhavvardhan/qutip,qutip/qutip,cgranade/qutip,zasdfgbnm/qutip,anubhavvardhan/qutip