fix getByLabel

This is a major clean-up, but I guess there is room for improvements, e.g.:
- more includes to be removed;
- use MessageLogger instead of `cout`