Timeout functionality and some fixes