Add workaround for "null dereference" build error in release mode. Fixes #847.