Better contract extraction.
Cleaned up contract extraction a bit.