Improved PATH handling according OS & fixed some minor bugs