fix warning
adding a ctx parameter to the write handler and some minor cleanups