Fixed a few errors and changed the bb building functions.