waitLoaded reference added, other minor changes