Rewrote script for better formatting. Added some safety checks and stuff.