Fix various loading bugs