Rework autoload handling (fixes #179, fixes #181)