support serializing objects of types like [B and float.
refactor code.