Reorganize code and write client documentation