Implemented integer rebinning. Needs testing!