Fix NPE error.
Still testing...