POST documents implementation

Many refactor