Refactorized. More pythonic architecture.
Refactorized