Merging core-wip into master.

Merging a previous version of core-wip into the core.

Not merging from the last commit since it does not compile properly on travis for now.