i dedicate this commit to mrout (some todos and a bit of refactoring)