Implements method to return next piece to send

Also remove code about threads.