Remove unused functions and modify some others