Closes #2, fixes #8 and closes #5