Warning analyzer fixes

Fix all warning and analyzer errors.