mod: rework plugin system
fix: make a block in main to avoid resource leaks