fixed various bugs