Cleanup of window size helper, and error checking