Code cleanup and changed ToJSON instances