Refactor some packet stuff.