Buckets of unorganized changes. Just finishing support for the doc() function.