Batch and SDE code to be moved to R