Cleanup of the code, example saving to a file