TTL checking added, and some fixes