Fixed some exception throws and other minor details