Fix code style and add comments