Fixing logical application and handle the special cases of records and variants (doesn't work yet)