Copied from https://code.google.com/p/rcaller/ under LGPL v3