Fixed performance for 'depend' clause and common performance improvements

72161c73d85329dfc766330e6cac76bb9875263c by Alexey Bataev