Refactoring update

More refactoring has been done, still not finished.