Updated to work correctly with cross-compiling