Add/update comments and doc comments; make minor tweaks.
Move lb_* function together in the source.