Refactoring some mess around :).
Updated refactoring.