Reworking upload and cat'ing. Some general bug fixes to avoid crashes as well