Added a healthy amount of exception handling