Preliminary work (porting from .NET client)