Adding code from fresh qscience distribution