Tidied up Newton solver to improve output in the event of nonconvergence. Also made it easier to swap between different types of residuals.