Refactoring function openWindow.
Fixed a bug in the removeChild.