NO-JIRA: code style update with some changes to the actual code (checks for null, undefined, simplified if/else, ...) (@ewant).