Fix class bugs