Fix warnings

Mostly use simpler forms. Remove unused variables.