Bugs fixing and documentation