Fixed error handling of gauss and inverse