Would still see NPE at certain cases despite fixes in #151, this takes care of it once and for all