Created by: Mr0maks
Based on https://github.com/Nyanotrasen/Nyanotrasen/pull/685 + a few fixes after all