refactor: some cleanup / refactoring

I'll annotate the diff where it could help understanding. Otherwise, minor modifs.

Great work on your side !