Reapplied Netty patch with some minor changes to fix login issues.