Hopefully fixed NPE - Untested