fixes #21, fixes #13, fixes #37