added code for finding type fo the file using magic.h
replaced openssl md5 with third party md5 implementation after BUSERROR in openssl md5. Other cleanup