Code cleanup. Got rid of a few internal functions that could be
better replaced with if/else statements. While it results in a
duplication of some code, it also gets rid of a lot of ternary
statements. The loss of the extra conditionals makes execution a
bit faster.