Remove some loops, and conversions