fixed some bugs. add last-window.