Rewrite to work with new libnpengine