Closes #2. Also additional work on #3, but will probably refactor again.