serious bug fixes

serious bug fixes