Add comments, Fix some errors and warnings