[WIP] Refactoring to replace many callbacks by promises