Fix code layout, fix tags support, fix minor bugs