Code optimization

Fixed around 100 warnings