Rework some modules to be better organized.
Fix some stuff for python 2.7