separated last steps so they can be run by root, added some improvements