Core improvements

I have done some improvements as you can see on the separate commits like keeping the environment for sudo, replaced hard coded plugin paths

This pull request have been split from #751.