Refactored code. Pretty happy now.