Code optimizing

Some hardware fixes