Fixed some bugs in cross-compile builds