Added a function to remove timeoutlen in certain cases. Not my work (thanks stackoverflow!).