Fixes and adapted to JSON