Major update to b.rb

Followed by minor inspection and tweaks.