Bug fix, add comments