Reworked the whole lib