clean up private internals
rename document -> doc to avoid confusion with DOM
improve formatting
Merge pull request #6 from svnlto/master

minor formatting and privates improvement