code changes and clean up