refactoring:
- move code in dedicated files
- change arguments from messages to constructor