Further performance improvements; fixes to layer control