margin and window autosizing enhancement