Fix an overflow and add blocking write (configurable)

 fixes #11 and #12