major refactoring, gui bug fixed