Fixes and enhancements to asserts

Fixes #250 and #251.