Better calculation of window size without scrollbars