Added exceptions, validation, and settings code.