code cleanup and network message magic