Mega refactoring

Adopt a more pythonesque structure