Added documentation and fixed a few things