Adding last of @kuba fixes from PR#9 Thanks!