Refactor giant conditionals
Merge remote-tracking branch 'origin/master'