Add test cases.
Move code around.
Improve error messages.