LERGO-463 - more refactoring and small changes to make the error appear more clearly.