This is duplicated from the original logfs so I don't want to introduce differences. Locally it's only used for ints so this should be ok though.