Code review fixes from mitio