Several enhancements to the LD functions