improved addPathToSystem, moved critical section