code cleanup and syntax improvements