WIP: Issue 26 patches

@adonath I'm trying to help finish this PR. Are you online?