[RFC] Rewrite history for PR 710

This is pr #710 with history rewritten(some temporary commits or commits that only aimed to fix errors in this PR were squashed/deletes). I did this to cleanup the PR history and opened this new PR to pass the commits through travis before merging(I will wait a couple of hours)