Added fail-safe insert + moved stdin reading to server mode only