cleaned up implementation for constructing core window; much cleaner and more efficient now