Bug fixes part 1