Class implementation slightly inspired by Python.