Added exceptions where needed and commented and documented what was lacking