Fix memory leak in PowerTool
Some code cleanup