WIP: Refactor, cleanup, docs
WIP: Move some functions to internal namespace