Update BDKp_library.php

many changes. some good (BC Math stuff), some a little bit dirty that may need fixing up.