Algebraic theory of locally nilpotent derivations