Merged clean_casts_to_speedup

Removed some unnecessary casts and fixed a small bug in operations