Added MIT License. Cleaned and redocumented code.