Fixed a major derp and an NPE in the process...