Closes #54. Tested and corrected.