Fix bug where previous tool is lost due editor reloading
Refactor mode changing