Do not chdir unless necessary
Prepend the ClassLoader autoloader to avoid calling other previously registered autoloaders, fixes #1699