Fix effects memory leak
Add `layer` and `unlayer` to kernel