Minor refactoring of error handeling.