remove unused imports. fix undefined names