fix bugs and build