minor code changes and cleanup