Rewritten handling of ByteArrayEntities. Added unit test for custom variable type.