Fix wrong cutting of directories (regression). Use splitpath