More cleanup: Organize imports, remove unnecessary casts and unused variables.