Move scope_exit to /common.
Fixed potential issues from formatting the fprintf input string.