fixed bugs in parsing and building markup