Cross-platform fixes to runtime