code cleanup and remove some unneeded functions