rewritten and packaged

split into a set of classes and added a setup.py file
to make installation easier.