Fixed some bugs for popup windows
Template changes.