Added exceptions and comments