Added null check. Fixes #490