code changes and fixes