Version 2.0

Full re-write of script.