Cleaning up some messy if-else blocks.