Improve notifications further

1) Add an option to auto-close the notification after N seconds
2) Clean up code