Cleanup and fixes from array to object