src: lots of refractoring