Resolves #16 and fixes #17