few changes to code to fix some minor issues