Some improvments in class handling