Robustifying: handling window scroll, resize and other events. Code-cleanup.