Fixes seemingly small IMPORTANT bug which caused huge memory errors.