Totally refactoring, not finished yet.