fixes #16 and #9