Fixed some accidental globals
Changed document state code to use actions. Callbacks added.
Merge branch 'rewrite' of https://github.com/josephg/ShareJS into rewrite