Refactored Database and JSON API