code cleanup and changes