minor code changes and fixes