Fixed the loading algorithm and other minor improvements