Issue #235 Fixing Windows Issues
diff --git a/action/create.go b/action/create.go
index d08857d..5a8d6c4 100644
--- a/action/create.go
+++ b/action/create.go
@@ -121,30 +121,22 @@
 
 	for _, pa := range sortable {
 		n := strings.TrimPrefix(pa, vpath)
-		root := util.GetRootFromPackage(n)
+		root, subpkg := util.NormalizeName(n)
 
 		if !config.HasDependency(root) {
 			msg.Info("Found reference to %s\n", n)
 			d := &cfg.Dependency{
 				Name: root,
 			}
-			subpkg := strings.TrimPrefix(n, root)
-			if len(subpkg) > 0 && subpkg != "/" {
+			if len(subpkg) > 0 {
 				d.Subpackages = []string{subpkg}
 			}
 			config.Imports = append(config.Imports, d)
 		} else {
-			subpkg := strings.TrimPrefix(n, root)
-			if len(subpkg) > 0 && subpkg != "/" {
+			if len(subpkg) > 0 {
 				subpkg = strings.TrimPrefix(subpkg, "/")
 				d := config.Imports.Get(root)
-				f := false
-				for _, v := range d.Subpackages {
-					if v == subpkg {
-						f = true
-					}
-				}
-				if !f {
+				if !d.HasSubpackage(subpkg) {
 					msg.Info("Adding sub-package %s to %s\n", subpkg, root)
 					d.Subpackages = append(d.Subpackages, subpkg)
 				}
diff --git a/action/get.go b/action/get.go
index ce20e84..38e6547 100644
--- a/action/get.go
+++ b/action/get.go
@@ -108,7 +108,7 @@
 			version = parts[1]
 		}
 
-		root := util.GetRootFromPackage(name)
+		root, subpkg := util.NormalizeName(name)
 		if len(root) == 0 {
 			return fmt.Errorf("Package name is required for %q.", name)
 		}
@@ -116,18 +116,9 @@
 		if conf.HasDependency(root) {
 
 			// Check if the subpackage is present.
-			subpkg := strings.TrimPrefix(name, root)
-			subpkg = strings.TrimPrefix(subpkg, "/")
 			if subpkg != "" {
-				found := false
 				dep := conf.Imports.Get(root)
-				for _, s := range dep.Subpackages {
-					if s == subpkg {
-						found = true
-						break
-					}
-				}
-				if found {
+				if dep.HasSubpackage(subpkg) {
 					msg.Warn("Package %q is already in glide.yaml. Skipping", name)
 				} else {
 					dep.Subpackages = append(dep.Subpackages, subpkg)
@@ -158,9 +149,8 @@
 			dep.Repository = "http://" + root
 		}
 
-		subpkg := strings.TrimPrefix(name, root)
-		if len(subpkg) > 0 && subpkg != "/" {
-			dep.Subpackages = []string{strings.TrimPrefix(subpkg, "/")}
+		if len(subpkg) > 0 {
+			dep.Subpackages = []string{subpkg}
 		}
 
 		if dep.Reference != "" {
diff --git a/cfg/config.go b/cfg/config.go
index 2aea716..de189eb 100644
--- a/cfg/config.go
+++ b/cfg/config.go
@@ -366,11 +366,10 @@
 	d.VcsType = filterVcsType(d.VcsType)
 
 	// Get the root name for the package
-	o := d.Name
-	d.Name = util.GetRootFromPackage(d.Name)
-	subpkg := strings.TrimPrefix(o, d.Name)
-	if len(subpkg) > 0 && subpkg != "/" {
-		d.Subpackages = append(d.Subpackages, strings.TrimPrefix(subpkg, "/"))
+	tn, subpkg := util.NormalizeName(d.Name)
+	d.Name = tn
+	if subpkg != "" {
+		d.Subpackages = append(d.Subpackages, subpkg)
 	}
 
 	return nil
diff --git a/godep/godep.go b/godep/godep.go
index b39deca..6785a0d 100644
--- a/godep/godep.go
+++ b/godep/godep.go
@@ -8,7 +8,6 @@
 	"encoding/json"
 	"os"
 	"path/filepath"
-	"strings"
 
 	"github.com/Masterminds/glide/cfg"
 	"github.com/Masterminds/glide/msg"
@@ -74,9 +73,7 @@
 
 	seen := map[string]bool{}
 	for _, d := range godeps.Deps {
-		pkg := util.GetRootFromPackage(d.ImportPath)
-		sub := strings.TrimPrefix(d.ImportPath, pkg)
-		sub = strings.TrimPrefix(sub, "/")
+		pkg, sub := util.NormalizeName(d.ImportPath)
 		if _, ok := seen[pkg]; ok {
 			if len(sub) == 0 {
 				continue
@@ -90,7 +87,7 @@
 		} else {
 			seen[pkg] = true
 			dep := &cfg.Dependency{Name: pkg, Reference: d.Rev}
-			if len(sub) > 0 {
+			if sub != "" {
 				dep.Subpackages = []string{sub}
 			}
 			buf = append(buf, dep)
diff --git a/repo/installer.go b/repo/installer.go
index c3db217..645d490 100644
--- a/repo/installer.go
+++ b/repo/installer.go
@@ -454,14 +454,16 @@
 		} else if v.Reference != "" && dep.Reference != "" && v.Reference != dep.Reference {
 			dest := filepath.Join(d.Destination, filepath.FromSlash(v.Name))
 			dep = determineDependency(v, dep, dest)
+		} else {
+			dep = v
 		}
 
+	} else if v != nil {
+		dep = v
 	} else if dep != nil {
 		// We've got an imported dependency to use and don't already have a
 		// record of it. Append it to the Imports.
 		d.Config.Imports = append(d.Config.Imports, dep)
-	} else if v != nil {
-		dep = v
 	} else {
 		// If we've gotten here we don't have any depenency objects.
 		r, sp := util.NormalizeName(pkg)
diff --git a/util/util.go b/util/util.go
index 502be52..409d400 100644
--- a/util/util.go
+++ b/util/util.go
@@ -287,7 +287,8 @@
 		}
 	}
 
-	root := GetRootFromPackage(filepath.ToSlash(name))
+	name = filepath.ToSlash(name)
+	root := GetRootFromPackage(name)
 	extra := strings.TrimPrefix(name, root)
 	if len(extra) > 0 && extra != "/" {
 		extra = strings.TrimPrefix(extra, "/")