Updated magnet interaction. Added demagnetize function.