Fix return code and printing of messages.