Simplify frame calculations

in an attempt to fix disappearing window issue