Fix segfaults, reorder files and set filename to exec