Removed old function and some code cleanup