onBeforeUnmount and onMount call fixes