Add null pointer check

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Remove unnecessary include

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Remove unused defines

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>