Improved reply parsing

Now all apparent bugs seems to be fixed :D

The whole architecture still needs refactoring.