Fixed improperly converting '~' in bridge

1. Off by one error by calling substr(0) instead of 1.
2. Also added a few TRACEs for good measure.