Fixed bugs and updated documentation