Fix bug where bottom gradient would overflow