Reformatted calls to R and E to prepare optimizations
Cleaned code structure to limit number of allocations and deallocations
of R and E