code cleanup & polishing