added md5 check + code cleanup