moved end_program to mlnmone.h, added error handling to some parts