fixed some bugs resulting from previous merge