Fixed a long-standing bug; it lived so long because I didn't use this script all this long :)