closes #9 plus some minor changes