added reference
Minor optimizations