Trimmed overflow and some useless code removed