major refactoring, gui bug fixed
major refactoring