Update comments and fix minor bugs