Fix some warnings and remove unused variables and imports.