Adds better error loggin.