added documentation, some function names has changed