Improved AB functionality

SOON! Hashed out most of the function (albeit with some repeated code)