New function to receive notifications.
Initial work, need a lot of tuning.