Changed the script quite a bit, it may actually be useful now.