Initual pass to fix magn 377
Implemented visibility saving on custom functions