Refactor and plugin fixes.