Cleaned up and finished packet handler