Refactoring, braking features and some bug fixes