Fixing redraw functions NaN and CSS changes