Added Documentation and fixed some bugs