First some classes and methods