Refactored into separate BART/API.pm module and added AnyEvent callback support.