Added possibility to load local files and structured the code a bit.