Cleanup of code, added specific exception