Added layer cache to speed up undo