Clarified code and switched to xrange
Extracted generators so they can be easily refactored later
Refactored no_black_border() and as a consequence, changed its threshold value