Refactor socket order and fix sprite bugs