Bugfixes and moving toJson into superclass