Cleaned up main patch a little bit.