Fixed NPE (fixed previous commit). #1050