FIX: a comparison with signed vs unsigned was solved. I'm reluctant to change this code since it is a vital piece.