Finishing off of exception handling. Also slight refactor