Refactored to use sqlite DB all over