Bug fix

Fixed a casting bug that only showed up in some older versions of Perl.