bug fixes and commenting