Added timeouts to prevent hangs

Added timeouts on while loops pertaining to i2c.
Added timeouts on while loops pertaining to CBS.