Code clean up. See NOTES file