Removing ifs and improving code quality

Comment From: pivotal-cla

@MaxNstk Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: snicoll

Same as the other two. Thanks for the PR, in any case!