Sync logic to reduce JS code.
More generic packet names.