fixed bugs as a result of previous merge.