This is a pretty epic method. Might be worth [extracting some methods](http://sourcemaking.com/refactoring/extract-method)?

P.S. that site I linked to is so awesome for learning practical refactoring patterns