Simplifying window code with some helper functions.