Tidy up and add nested JSONWritable support