Added document state-keeping classes, started to implement server logic