Made few small changes so that it runs.
Merge pull request #1 from HugoFeng/fix_bugs

Made few small changes so that it runs.