Code cleanup. See NOTES