First working version. Made for HKU as an experiment.