Fixed a few bugs, program will now work correctly.