Proper ID handling + make history a sorted-set