merged from https://github.com/anyc/mplugd