Rewrote packet handling.
The previous version used code that wasn't allowed to be used apparently
which also could cause some compilation errors.