Some minor bugs fixed