Support for connection on an occupied terminal + code style & perf