Reducing chunk size to prevent overflow
Moved import statement to beginning of file
Removed window component to it's own set of functions for easy import