Fix bugs in notifications

and also a minor bug in the function for writing data '_write'