Fix minor bugs, add comments