LoadFile optimizations (copied wholesale)