Fixed an NPE caused by an incomplete refactor