Reorganized packet handeling code out of main class

This gets rid of a lot of code duplication related to the client/server nature of a proxy, making the remaining code easier to maintain.