Merge code
Fixed idToWindow(), still busy looping