Fix potential LFS related issues

This patch-set supersedes the #3 PR (but needs testing on Solaris)