Fixes issue #673

 Most credit to @jewel for code. Mine differs only in the order of else's so that the minified version works.