Clean up and format notification related stuff, fix some bugs