Tried to make it a little neater and more modular

I haven't touched python since freshmen year and I can't even test this, so I hope this works?

Variable names like "dafile" are not only unhelpful but are actively misleading - it was often in fact a directory. Do not feel compelled to re-use variables in multiple contexts, you won't save memory and will just cause confusion. 

Those comments had to go.