improvements

various improvements, see commit log for details.