Improved handling of plugin loading, as well as debug logging