Working version of resize with debug printf statements.
Working version without debug statements.