code cleanup and fixes due to last commit