Some fixes in loader code