fixed the initial flicker on click, various performance improvements