fixes #5 and #22