Add docs and fix some memleaks