Add recursive check for changes in types, add more tests, change to JSON serialization, clean up code