Refactor main (extract methods getPluginManager and getEventService).