Layer now properly handles not being in a function