Little more cleanup. Not sure how to reduce complexity though..