Fixing various bugs across platforms