Move serialize method so class id defined