Some cleanup

Changed some heap allocations to stack ones, fixed spacing, removed unused return value, flattened nested if-statements, changed exit_success on error to exit_failure.