Plugin cleanups and bugfixes (issue #383, issue #547)