Added a license and used 'assert' instead of my own 'exit_with_error' function.