Fixed bugs in adaptive integration