Seems this is due to how Erlang handles binaries and references: http://dieswaytoofast.blogspot.co.uk/2012/12/erlang-binaries-and-garbage-collection.html
my solution is to just have a macro defining the function which should be used, and switching that for a fake function at compile time, seems to work for now