Rewritten server to only close connection if idle for 1 second. Fixed path-depth function as it was always 1 less than original version