Optimizations and remove some useless things

Change-Id: If304b61c00450c4169bb618c6cb158775cfebcfd