= fixed some ugly parts of lib/protocol