Cleaned up code, fixed up documentation.