fixed some new bug and updated the gui code to speed it up.