Clean up structure of problem code

There's something fishy here, the ShiWarning() in this method is being
triggered on startup. I fixed some of the nasty layout of the code here.