Fixed a few issues and added documentation