Better templating system
Seems to work. TODO: prettify code, there are duplicated stuff. Streamline repeated attempts in a while() block with an increasing sleep()