Added irr function and some cleanups.