massive code reorganisation, bugs expected, not done yet