Fix the removeFunctions() function, implement function to modify parent elements