fixes #91 and tries to prevent some unnecessary layouts each frame