Fix runtime error related to nil device id
Support 64-bit builds