Doc, and cleanup of core functions.