fix sampling bug where only 100%+ and 0% were possible
add heartbeat callback API code and python wrapper