First working version of the new API.

Currently only client uses new API implementation, server uses the old one.