expan() function replaces some of the calls to os.path to make code cleaner. If two values are passed it joins them.
Replaced all instances of os.path.join() with expan()