Basic refactoring is done, no testing yet though.