fixed a set of minor bugs