add support for protected layers, unload plugins on exit