Cleanup and API improvements