Core: Revised the initial version of code sent by Emma.