reworked load.static script to make it more modular, and reworked main function to minimize memory overhead