This closes #4 and #1