code cleanup and fixed header