Basic classes and some useful functions