[4.2] Fix groupBy() bug

As described here
https://github.com/laravel/framework/pull/4276#issuecomment-45563986 by
@JosephSilber
Prevent array_forget() from mixing up references
Merge pull request #5715 from jchamberlain/array_forget

Prevent array_forget() from mixing up references
Merge pull request #5061 from KennedyTedesco/4.2-groupBy

[4.2] Fix groupBy() bug
Cleaning up code.
Merge branch '4.2'