Fixed a bug and added docs