fixed some segfaults and fixed opening of window in "open form in new window"