Refactor master

This is good to merge.