I've seen something very similar in another thread. You might find some parts of that article helpful, not everything of course, but I believe it is worth looking into.
http://reparacionordenador.es/writing-a ... simple-56/
http://mpbajka.elk.edu.pl/2016/10/21/th ... iting-156/