fix expire function

if max size limit is reached remove the oldest versions until the size limit is met. Always keep at least the two latest versions.