Improvements and new features, due to my thesis work.