Fixed a recursion bug and a few minor issues.