merge patches and fixes from SuperNexus, credits: Faryaab