Logic fixes

Closes #8.