Clean up code.

- Use assertions for conditions that should never be true.
- Tidy variable names.
Add Travis YAML.