Moved minimalt stuff into separate file, switched to base64 for printing, used streams instead of keeping indexes, compacted control messages.