improved messaging and added asserts