fixed packet system to not cause memory leaks