Fix a crash and improve efficiency in plugins...