More cleaning/refactoring. I believe I've now standardized it so that all functions that take strings take unicode strings.