Improved accuracy in some function by using doubles instead of reals. All functions (where possible) split into two versions with per atom output and overall output.