"minor refactoring"

@martin-g if you've some spare time feel free to review this pr ;)