Merge recent developments to stable API

@autermann these are basically your adjustements. Do you think they are stable enought for the master branch?