some code cleanup and minor updates