fix bugs and add misc features