reorganized server code and added search/indexing to drafts/templates