Attempts to fix segfaults noted in issue #11