Bug fixes; closes #22, closes #33