Rewrite. API changes.

Signed-off-by: Fadion Dashi <jonidashi@gmail.com>