Refactor core into plugins with command and subcommand scripts