Change cleanup and process functions to return results