Added comments and unfold deep "if"-construct in timeout_handler