Code optimized and tested.