formatted code.. added support for create document..
More bug fixes to come.