Rewritten

most of it was rewritten (lib)