Fix unsigned integer overflow.

1. Missing parenthesis caused unsigned integer overflow in quicksort
   implementation.
2. Fixes an issue where garbage is being collected multiple times in a
   row causing memory issues.