[5] Code cleanup and miscellneous fix

* cache function result in local variables

* Update the logic of generating notification date header

Change-Id: I04c3ed853076f17c819da8f27bfdb169e99b2a3a
Merge "[5] Code cleanup and miscellneous fix"