Modified to deal with problematic internal coordinate optimizations