This major patch closes #11 and #12 and resolves #5