Fix/report write failure handler

Note that this is based on top of #164