Cleanup, rename functions, more docs