added some last-minute bug fixes