Strengthened invariants.

Made assertions a bit more interesting for the exercise.