Ensure filesize is saved (and code cleanup)