Cleanup for function.