Fix return value inconsistencies in loader.c