added environments and substitution to core
cleaned up source defs