Refactor clean

Clean up the code to mach the new API.