Added option to use different database or table for history