Lot of improvements and fixes, the script is almost usable now