This whole section of code was already a mess, so I guess this isn't any worse ;)