Cleaned up for open-source.