Weird mixups in native embedded client

These fixes is founded by using fbembed server on x64 OS.
Maybe some fixes should be discussed.
Interesting. That must have been there for ages. Shouldn't we change all ToInt32 calls (probably wrapping it to some method)?