Document model and core functions