bugfix, return if allocation fails
refactor callbacks into callback.h/c