Code Inspector improvements

Change coding issues raised by code inspector.
Still some remain to fix.