Cleaned up some code and updated the documentation.