Start to refactor plugin directive

Works on #348