Some cleanup of code:
- type-hint objects when possible,
- don't use container parameter in constructor
- reduce usage of container
- remove some code duplication