Fixed out bugs + added embed/unembed, refer/unrefer functionality