Rearrange library, add schema, handle load of document, lot of fix