Tweaking the APIs and adding JSON serialization.