Added exceptions, refactored global methods