Fixes and refactorings after running BEAM (GPF) tests.
fixed API doc
fixed tests