Fixing some bad code