As pointed out by HarryC, we need to do nullpointerchecks here.