fixed various bugs and typos