fixes #3, fixes #16, and fixes #23