add documentation and misc fix