Update net codes and fix session issues from the refactoring
Simplify type assertions