Cleanup

Refactor specs and improve their semantics; fix shebang in executable.