Fixed errors due to weird C# behaviour with bitwise operations.