Bug fixes and initial commit surface energy error correction