bug fixes and commenting part 1