Fix nid decoding logic
Refactor imports