fixed various bugs and comments