Layer support and bugfixes