fix compile errors and tests
writing docs