Added Brain's fixes to the library.