Fixed some weird stuff and added folder handling.
Added eternal caching of file once generated.