Re-implement Window class to support better error checking