Refactoring

A few improvements…
Refactoring + bug fixes + improvements