fix bugs and small changes