fixes #332, #334 and other visual glitches