Bugfix: some crashes when changing layers on graphics.