Improve error handling

Trap error signals to print backtraces