Rebase onto master and fixing merge conflict

I've rebased this fork and fixed the merge conflict. It can now be merged into master without any issues if/when the time comes.

Rebasing also introduced some changes that fixed the Travis tests which were previously failing.