Fixed bugs.
Updated with the changes to master branch.